package testJdk.commonUse.string;

import org.junit.Test;

/**
 * @author keyer
 * @Description : 描述
 * Created by cyd on 2021-04-23 17:34:59
 */
public class TestString {
    String str = new String("hello");
    char[] chars = {'t', 'e', 's', 't'};

    /**
     * 测试引用传递
     *
     * @param str   传入的str无法替换成员变量
     * @param chars 传入的字符可以改变成员变量
     */
    public void change(String str, char[] chars) {
        str = "test ok";
        chars[0] = 'b';
    }

    /**
     * 测试引用传递
     */
    @Test
    public void test() {
        TestString testString = new TestString();
        testString.change(testString.str, testString.chars);

        System.out.println(testString.str);
        System.out.println(testString.chars);
    }

    @Test
    public void test_getInteger() {
        String str = "2021-12-09-11";
        String time = str.substring(str.length() - 2, str.length());
        System.out.println(time);
        System.out.println(Integer.getInteger("abc"));
        System.out.println(Integer.getInteger("123"));
        // getInteger不好用，用valueOf
        System.out.println(Integer.valueOf(time));
    }

}
